class Floder {
    constructor(name) {
        this.name = name;
        this.files = []
    }

    add (f) {
        this.files.push(f)
    }

    scan() {
        console.log("开始扫描文件夹：",this.name);
        for (let i = 0,file,files = this.files;file = files[i ++ ];) {
            file.scan()
        }
    }
}
class File {
    constructor(name) {
        this.name = name;
    }

    add() {
        throw new Error("文件不能添加文件夹")
    }

    scan() {
        console.log("正在扫描文件：",this.name);
    }
}
const A = new Floder("前端")
const a = new Floder("javascript设计模式与开发实践")
const b = new Floder("node")
const c = new Floder("webpack")
const d = new Floder("vue")
const e = new File("vuejs设计")
const f = new File("node深入浅出")
const g = new File("webpack打包优化")
const h = new File("javascript设计模式")
a.add(h)
b.add(e)
c.add(f)
d.add(g)
A.add(a)
A.add(b)
A.add(c)
A.add(d)

A.scan()
